//
//  TestView.m
//  Coding_My
//
//  Created by showXxie on 2017/8/21.
//  Copyright © 2017年 sooxie. All rights reserved.
//

#import "TestView.h"

@implementation TestView


- (void)setFrame:(CGRect)frame {
    //旧值  self.frame
    CGFloat oldheightToBottom = kScreen_Height - CGRectGetMinY(self.frame);
    //新值 frame
    CGFloat newheightToBottom = kScreen_Height - CGRectGetMinY(frame);
    
    //执行super方法后改变值
    [super setFrame:frame];
    
    NSLog(@"%s",__func__);
}

- (instancetype)initWithFrame:(CGRect)frame {
    self =  [super initWithFrame:frame];
    if (self) {
        
        UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _loginBtn = loginBtn;
        [self addSubview:loginBtn];
        loginBtn.backgroundColor = kColorBrandGreen;
        
       [loginBtn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
        
        UITextField *tf = [[UITextField alloc]init];
        [self addSubview:tf];
        tf.backgroundColor = [UIColor whiteColor];

        UILabel *label = [[UILabel alloc]init];
        [self addSubview:label];
        label.backgroundColor = [UIColor whiteColor];

        
        [loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.equalTo(self).offset(20);
            make.left.equalTo(self).offset(20);
            make.right.equalTo(self).offset(-20);
            make.height.mas_equalTo(44);
            
        }];
        
        [tf mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.equalTo(loginBtn.mas_bottom).offset(5);
            make.left.equalTo(self).offset(20);
            make.right.equalTo(self).offset(-20);
            make.height.mas_equalTo(44);
            
        }];
        
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.equalTo(tf.mas_bottom).offset(5);
            make.left.equalTo(self).offset(20);
            make.right.equalTo(self).offset(-20);
            make.height.mas_equalTo(44);
            
        }];
        
        
        
        RAC(label,text) = tf.rac_textSignal;

        
      
        
    }
    
    return self;
}

- (void)click {
    
    NSLog(@"loginBtnloginBtnloginBtn");
    
}

@end
